﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
using System.Data.SqlClient;

namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        /// <summary>
        ///     Executes the bulk action.
        /// </summary>
        public void ExecuteBulkAction()
        {
            if (!string.IsNullOrEmpty(SqlActionBulk1))
            {
                using (var sqlCommand = new SqlCommand(SqlActionBulk1, SqlConnection))
                {
                    sqlCommand.Transaction = SqlTransaction;
                    sqlCommand.ExecuteNonQuery();
                }
            }

            if (!string.IsNullOrEmpty(SqlActionBulk2))
            {
                using (var sqlCommand = new SqlCommand(SqlActionBulk2, SqlConnection))
                {
                    sqlCommand.Transaction = SqlTransaction;
                    sqlCommand.ExecuteNonQuery();
                }
            }
        }
    }
}